/**
 * Created by Administrator on 2017/4/10 0010.
 */
Btn1=function(getWidth,getHeight,context){
        // var btn={enabled:true};
        var whole=new PIXI.DisplayObjectContainer();
        var bl_clicked=false;
        whole.enabled=true;

        var frame=new PIXI.Graphics();
        frame.lineStyle(1,0x7fffff,1);
        frame.moveTo(0,0);
        frame.lineTo(getWidth,0);
        frame.lineTo(getWidth,getHeight);
        frame.lineTo(0,getHeight);
        frame.lineTo(0,0);
        whole.addChild(frame);

        var bg=new PIXI.Graphics();
        bg.beginFill(0x000000,1);
        bg.drawRect(0,0,getWidth,getHeight);
        whole.addChild(bg);


        var frameBG=new PIXI.Graphics();
        frameBG.beginFill(0x00fffc,0.6);
        frameBG.drawRect(0,0,getWidth,getHeight);
        whole.addChild(frameBG);
        frameBG.alpha=1;
        frameBG.x=-getWidth-1;

        var frameBGMask=new PIXI.Graphics();
        frameBGMask.beginFill(0x000000,1);
        frameBGMask.drawRect(0,0,getWidth,getHeight);
        whole.addChild(frameBGMask);
        frameBG.mask=frameBGMask;




        var text= new PIXI.Text(context,{fontFamily : 'Arial', fontSize: 20, fill : 0x7fffff, align : 'center'});
        text.x=getWidth/2-text.width/2;
        text.y=getHeight/2-text.height/2;
        whole.addChild(text);

        var grayWhole=new PIXI.Sprite();
        var grayBG=new PIXI.Graphics();
        grayBG.beginFill(0x999999,1);
        grayBG.drawRect(0,0,getWidth,getHeight);
        grayWhole.addChild(grayBG);
        var grayText= new PIXI.Text(context,{fontFamily : 'Arial', fontSize: 20, fill : 0x000000, align : 'center'});
        grayText.x=getWidth/2-grayText.width/2;
        grayText.y=getHeight/2-grayText.height/2;
        grayWhole.addChild(grayText);
        grayWhole.alpha=0;
        whole.addChild(grayWhole)



        whole.interactive=true;
        whole.on("pointerover",function(){
            if(whole.enabled){TweenMax.to(frameBG,0.4,{x:0,ease:Cubic.easeOut});}
        })
        whole.on("pointerout",function(){
            if(whole.enabled){TweenMax.to(frameBG,0.4,{x:-getWidth-1,ease:Cubic.easeOut});}
        })
        whole.upWord=context;
    whole.downWord="None";
    whole.getDownWord=function(getWord){
        whole.downWord=getWord;
        }

        whole.on("pointerdown",function(){
            if(whole.enabled) {
                if (bl_clicked == false) {
                    bl_clicked = true;
                    if (whole.downWord != "None") {
                        text.text = whole.downWord;
                    }
                }
                else {
                    bl_clicked = false;
                    text.text = whole.upWord;
                }
            }
        })
        whole.downState=function(){
            return bl_clicked;
        }

        whole.setGray=function(bl){
            whole.enabled=bl;
            if(bl_clicked){
                grayText.text=whole.downWord;
            }
            else{
                grayText.text=whole.upWord;
            }
            if(!bl) {
                whole.interactive=false;
                TweenMax.killTweensOf(grayBG);
                TweenMax.to(grayWhole, 0.7, {alpha: 1, ease: Cubic.easeOut});
                TweenMax.to(frame, 0.7, {alpha: 0, ease: Cubic.easeOut});
            }
            else{
                whole.interactive=true;
                TweenMax.killTweensOf(grayBG);
                TweenMax.to(grayWhole, 0.7, {alpha: 0, ease: Cubic.easeOut});
                TweenMax.to(frame, 0.7, {alpha: 1, ease: Cubic.easeOut});
            }
        }
        whole.reset=function(){
            bl_clicked=false;
            grayText.text=whole.upWord;
            text.text=whole.upWord;
        }



        return whole;

}
